package com.smartao.base.entityitem;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.smartao.base.Constant;
import com.smartao.base.init.InitializeServiceOrder;
import com.smartao.base.module.ModuleService;
import com.smartao.core.init.AbstractDataInitializeService;

/**
 * 初始化实体对象配置
 * @author Ricky
 */
@Service
public class EntityitemInitializeService extends AbstractDataInitializeService {

	protected final int order = InitializeServiceOrder.INIT_ORDER_ENTITY;

	@Autowired
	private EntityitemService entityitemService;
	@Autowired
	private ModuleService moduleService;

	@Override
	public void initData() throws Exception {
		Entityitem entityitem = entityitemService.findByEntityKey(Constant.ENTITY_KEY_EMPLOYEE);
		if(entityitem==null){
			entityitem = new Entityitem();
			entityitem.setEntityKey(Constant.ENTITY_KEY_EMPLOYEE);
			entityitem.setName("员工");
			entityitem.setDescription("系统内置员工对象");
			entityitem.setModule(moduleService.findByModuleKey(Constant.MODULE_BASE));
			entityitem.setHref("#");
			entityitem.setTarget("/base/employee/employee!queryForSelect.action");
			entityitemService.save(entityitem);
		}
	}

	@Override
	public int getOrder() {
		return order;
	}

}
